﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace WikiTrailCreator.TrailImages
{
    public class TrailImage
    {
        private Guid id = Guid.NewGuid();
        public string DisplayText;
        private string localPath;
        public string GalleryCaption;
        public string PageText;
        private Image image;

        public TrailImage(string displayText, string localPath)
        {
            this.DisplayText = displayText;
            this.LocalPath = localPath;
        }

        public TrailImage(Guid id, string displayText, string localPath)
        {
            this.id = id;
            this.DisplayText = displayText;
            this.LocalPath = localPath;
        }

        public override string ToString()
        {
            return DisplayText;
        }

        public string LocalPath
        {
            get
            {
                return localPath;
            }
            set
            {
                localPath = value;

                Image imageBig = Image.FromFile(localPath);

                float scale = (float) ((float)imageBig.Width / 200.0);
                int newWidth = (int) ((float) imageBig.Width / scale);
                int newHeight = (int) ((float) imageBig.Height / scale);

                image = new Bitmap(imageBig, newWidth, newWidth);
            }
        }

        public Image Image
        {
            get { return image; } 
        }

        public Guid Id
        {
            get { return id; }
        }
    }
}
